package punctuatedEquilibrium;

public class FloatComparison {
	private static final int	TOLERABLE_ERROR_EXPONENT	= 12;

	public static double tolerableErrorDependingOnExpectedValue(
			double expectedValue) {
		return expectedValue / Math.exp(TOLERABLE_ERROR_EXPONENT);
	}

	public static boolean equals(double expected, double actual) {
		double tolerableError = tolerableErrorDependingOnExpectedValue(expected);
		double signLessDifference = Math.abs(expected - actual);
		return signLessDifference < tolerableError;
	}
}